#include <bits/stdc++.h>
const int MAX_SIZE = 100;
using namespace std;
/* file.in
3 4
1 2 2 3
2 0
3 1 2
1 2
1 3
1 1
0 2
*/
/* result should be
1
2
3
0 since 2 closed and 1,3 cannot open
*/
typedef struct Node *PtrToNode;
struct Node
{
    int id;
    PtrToNode next;
};
typedef struct AllNode
{
    bool opened;
    PtrToNode next;
}WholeNode[MAX_SIZE];
int main() 
{
    freopen("file.in","r",stdin);
    int n, q, n2v, indegree[MAX_SIZE]={0}, v, count, fv;
    WholeNode Allv;
    PtrToNode temp;
    cin >> n >> q;
    // init
    for (int i = 1; i < n+1; i++)
    {
        Allv[i].next = NULL;
        Allv[i].opened = false;
    }
        

    for (int i = 0; i < n; i++)
    {
        cin >> fv >> n2v;
        indegree[fv] = n2v;

        for (int j = 0; j < n2v; j++)
        {
            temp = (PtrToNode)malloc(sizeof(PtrToNode));
            cin >> v;
            temp->id = fv;
            temp->next = Allv[v].next;
            Allv[v].next = temp;
        }
    }
    for (int i = 0; i < q; i++)
    {
        cin >> n2v >> v;
        if (n2v == 1 && indegree[v] == 0)
        {
            if(!Allv[v].opened)
            {
                Allv[v].opened = true;
                
                temp = (PtrToNode)malloc(sizeof(PtrToNode));
                temp = Allv[v].next;
                while (temp != NULL)
                {
                    indegree[temp->id]--;
                    temp = temp->next;
                }
            }
            cout << ++count << endl;
        }
        else if(n2v == 0 && Allv[v].opened)
        {
            // 如果曾经有过，拓扑需要重新加 入度
            // 并且基于这个节点而开启都被迫需要关闭 因为前置条件不满足了
            // for close one
            count--;
            Allv[v].opened = false;
            temp = (PtrToNode)malloc(sizeof(PtrToNode));
            temp = Allv[v].next;
            while (temp != NULL)
            {
                indegree[temp->id - 1]++;
                // for needed
                if(Allv[temp->id].opened)
                {
                    Allv[temp->id].opened = false;
                    count--;
                }
                temp = temp->next;
            }
            cout << count << endl;
        }
            
    }
    return 0;
}
